-- @owner: @wan005
-- @date: 2022/01/07
-- @testpoint: insertpt index-- 全局临时表创建索引 事务提交

--step1:建表;expect:成功
drop table if exists t_ustore_insert_0034 cascade;
drop index if exists index_ustore_0034;
create global temp table t_ustore_insert_0034(
c_id int,
c_d_id int,
c_w_id int,
c_first varchar(16),
c_middle char(16),
c_last varchar(16)
) with (storage_type=ustore) on commit delete rows;

--step2:全局临时表创建索引，事务提交;expect:成功
create index index_ustore_0034 on t_ustore_insert_0034(c_id) with (indexsplit=insertpt);
analyze t_ustore_insert_0034;
begin;
insert into t_ustore_insert_0034 values (generate_series(1,140000),generate_series(1,140000),generate_series(1,140000),'abc','cde','fds');
select count(*) from t_ustore_insert_0034;

select count(*) from t_ustore_insert_0034 where c_id between 10000 and 20000;
explain  (costs false)  select count(*) from t_ustore_insert_0034 where c_id between 10000 and 20000;
commit;
/
select count(*) from t_ustore_insert_0034;
select relname from pg_class where oid in  (select indexrelid from pg_index where indrelid = (select oid from pg_class where relname ='t_ustore_insert_0034'));

select count(*) from t_ustore_insert_0034;

--step3:清理环境;expect:成功
drop table if exists t_ustore_insert_0034;